package org.bp.test;

import java.io.File;
import java.io.FilenameFilter;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.bp.util.FileUtils;

public class Wf {
	static LocalDateTime localDateTime = LocalDateTime.of(LocalDate.of(2018, 5, 29), LocalTime.MIN);
	public static void main(String[] args) {
		List<String> list = FileUtils.loadTextInLineFromFile(new File("D:/Temp/2.txt"), "UTF-8");
		List<String> begins = new ArrayList<>();
		List<String> ends = new ArrayList<>();
		list.forEach(action->{
			String[] split = action.split(";");
			begins.add(split[0]);
			ends.add(split[1]);
		});
		begins.forEach(action->{
			if(ends.contains(action)){
				System.out.println(action);
			}
		});
		System.out.println("--------------------------");
		ends.forEach(action->{
			if(begins.contains(action)){
				System.out.println(action);
			}
		});
		System.out.println("恭喜你哦");
	}
	
	public static void visit(File file){
		file.listFiles(new FilenameFilter() {
			@Override
			public boolean accept(File dir, String name) {
				File file = new File(dir, name);
				if(file.isDirectory()){
					visit(file);
				}
				if(file.isFile()){
					long lastModified = file.lastModified();
					Date date = new Date(lastModified);
					LocalDateTime time = castLocalDateTime(date);
					if(time.isAfter(localDateTime)){
						System.out.println(file.getAbsolutePath());
					}
					return true;
				}
				return false;
			}
		});
	}
	
	public static LocalDateTime castLocalDateTime(Date date){
		Instant instant = date.toInstant();
        ZoneId zoneId = ZoneId.systemDefault();
        return instant.atZone(zoneId).toLocalDateTime();
	}
}
